package com.qidianit.mes.pro.controller;

import com.github.pagehelper.PageInfo;
import com.qidianit.mes.pojo.Result;
import com.qidianit.mes.pojo.pro.WorkflowProcess;
import com.qidianit.mes.pro.service.WorkflowProcessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Description:
 * @Author: YanJiRan
 * @Date: 2025/9/18 - 下午8:21
 */
@RestController
@RequestMapping("/workflowProcess")
public class WorkflowProcessController {
    @Autowired
    private WorkflowProcessService workflowProcessService;
    @GetMapping("/page")
    public Result<PageInfo<WorkflowProcess>> list(WorkflowProcess workflowProcess, @RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "10") int size){
        return workflowProcessService.selectList(workflowProcess,page,size);
    }

    @PostMapping("/add")
    public Result<WorkflowProcess> save(@RequestBody WorkflowProcess workflowProcess){
        return workflowProcessService.saveWorkflowProcess(workflowProcess);
    }

    @GetMapping("{id}")
    public Result<WorkflowProcess> getByCode(@PathVariable("id") Long workflowProcessId){
        return workflowProcessService.selectById(workflowProcessId);
    }

    @PutMapping("/update")
    public Result update(@RequestBody WorkflowProcess workflowProcess){
        return workflowProcessService.updateById(workflowProcess);
    }

    @DeleteMapping("/delete/{id}")
    public Result deleteById(@PathVariable("id") Long workflowProcessId){
        return workflowProcessService.deleteById(workflowProcessId);
    }

    @DeleteMapping("/batchDelete")
    public Result batchDelete(Long[] id){
        return workflowProcessService.batchDelete(id);
    }
}
